// Learn TypeScript:
//  - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html

const {ccclass, property} = cc._decorator;

@ccclass
export default class NewClass extends cc.Component {

    
    onLoad () {
        this.node.on(cc.Node.EventType.TOUCH_MOVE, this.moveHandler, this)
    }

    start () {

    }

    moveHandler(e: cc.Event.EventTouch){
        const delta = e.getDelta();
        this.node.x += delta.x;
        this.node.y += delta.y;
    }

    // update (dt) {}

    onCollisionEnter(other: cc.Collider, self: cc.Collider){
        cc.log(`友机：${other.tag} ${self.tag}`)
        if(other.tag === 0){
            cc.log('友机死了')
        }else if(other.tag === 2){
            cc.log('敌机死了')
        }
    }

    onCollisionStay(other, self){

    }

    onCollisionExit(other, self){

    }
}
